package com.justnow.offer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author justnow
 * Created on 2020-10-11
 * Description
 */
public class Youzan01 {
    public boolean isSubsequence (String s, String t) {
        // write code here
        List<Integer> array = new ArrayList<>();
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i) == t.charAt(j)) {
                    array.add(j);
                }
            }
        }
        boolean res;
        int size = array.size();
        if (size < s.length()) {
            res = false;
            return res;
        }

        for (int i = 0; i < size - 1; i++) {
            if (array.get(i) > array.get(i + 1)) {
                res = false;
                return res;
            }
        }

        return true;
    }
}
